const app = getApp()
import { formatTime } from '../../utils/util'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    leval: ['非常不满意', '不满意', '一般', '满意', '非常满意'],
    levalCount: 5,
    lev:'非常满意'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this
    app.data.out = 'chu'
    wx.setNavigationBarColor({
      frontColor: '#ffffff',
      backgroundColor: '#ca151d'
    })
    this.setData({
      avatarUrl: wx.getStorageSync("userInfo").avatarUrl,
      nickName: wx.getStorageSync("userInfo").nickName
    })
    let mins = options.min.split(',')
    let sec = options.sec.split(',')
    let flag = true
    if (mins<30){
      flag = false
    }
    this.setData({
      mins,
      sec,
      flag
    })
  },
  choose(e) {
    const levl = this.data.leval
    const index = e.currentTarget.dataset.index
    this.setData({
      levalCount: index,
      lev: levl[index]
    })
  },
  submit(){
    const that = this
    const leval = that.data.levalCount + 1
    wx.request({
      url: app.data.url + '/get_outinfo',
      method: 'POST',
      header: app.getHeader(),
      data: {
        oncustomer_id: wx.getStorageSync('openid'),
        stars: leval,
        comment: that.data.lev
      },
      success: function (res) {
        that.setData({
          ti: true
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '质能健身站',
      path: '/pages/welcome/welcome',
      success: function (res) {
      },
      fail: function (err) {
        console.log(err)
      }
    }
  }
})